#include "evdeploy/core/ev_deploy.h"
#include "evdeploy/core/ev_model_adapter.h"
#include "version_config.h"

namespace ev
{

EVModelAdapter& GetModelAdapter()
{    
    static EVModelAdapter& adapter = EVModelAdapter::GetAdapter(); 
    return adapter;
}


EVDeploy::EVDeploy()
{    
    
}

EVDeploy& EVDeploy::GetModel()   
{
    static EVDeploy model;
    return model;
}

bool EVDeploy::InitModel(const std::string& config_file)
{
    EVLOG(INFO) << "EVDeploy VERSION is " << EVDeploy_VERSION;
    return GetModelAdapter().InitModel(config_file);    
}

bool EVDeploy::CreateModel(const std::string& uuid)
{
    return GetModelAdapter().CreateModel(uuid);
}

bool EVDeploy::RunInfer(const std::string& uuid, EVModelData* inputs, EVModelData* outputs)
{
    return GetModelAdapter().RunInfer(uuid, inputs, outputs);
}

bool EVDeploy::DestroyModel(const std::string& uuid)
{
    return GetModelAdapter().DestroyModel(uuid);
}

bool EVDeploy::GetVersion(std::string& version)
{    
    version = EVDeploy_VERSION;
    return true;
}

extern "C" char * GetVersion()
{
    std::string STR_EMS_VERSION = EVDeploy_VERSION;
    char *ptr = (char*)calloc( STR_EMS_VERSION.size() + 1, 1);
    memcpy(ptr, STR_EMS_VERSION.c_str(), STR_EMS_VERSION.size());
    return ptr;
}


}//end namespace ev